using System;

namespace RapidHDL
{
	/// <summary>
	/// Summary description for Clock.
	/// </summary>
	public class ClockComponent
	{

		public delegate void ClockEdgeEvent(long timeNow);

		System.Collections.ArrayList oRisingClockEdgeEvents;
		System.Collections.ArrayList oFallingClockEdgeEvents;

		public NodeVector ClockEnable;
		public NodeVector ClockOut;

		// frequency
		
		// on creation, register with the simulation clock
		//		for periodic events
		// raises event & latches others
		// 
		// list of registers to update
		public ClockComponent(Component poParentComponent, string psName) 
			: base (poParentComponent,psName)
		{
			ClockEnable = this.CreateNodeVector("In",1,NodeFlowType.Sink);
			ClockOut = this.CreateNodeVector("Out",1,NodeFlowType.Source);	
		}

		public override void CalculateOutput()
		{
			// Nothing
		}

		public override bool TransformStructureToVerilog()
		{

		}

		public void LinkRegister(RegisterComponent oRegisterComponent)
		{
			if (!oRegisters.Contains(oRegisterComponent))
				oRegisters.Add(oRegisterComponent);
		}

		public void UnlinkRegister(RegisterComponent oRegisterComponent)
		{
			if (oRegisters.Contains(oRegisterComponent))
				oRegisters.Remove(oRegisterComponent);
		}

	}
}
